#ifndef XCUSTOMCHART_H
#define XCUSTOMCHART_H

#include <QtCharts/QChart>

QT_CHARTS_USE_NAMESPACE

QT_CHARTS_BEGIN_NAMESPACE
class QLineSeries;
QT_CHARTS_END_NAMESPACE

//自定义控件
class XCustomChart : public QChart
{
    Q_OBJECT
public:
    XCustomChart(QGraphicsItem* parentItem);
    virtual ~XCustomChart();

    void getNearestPoint(const QPointF& ptSeries);  //获取最近的点
    qreal distanceOf(const QPointF& point1, const QPointF& point2); //获取两点距离
    void modifyCurve(const QPoint& ptInView);   //修改指定点处的曲线
    void setModifyFlag(bool b); //设置修改标志
    bool map2Series(const QPoint& ptInView, QPointF& ptInSeries) const;

public slots:
    void slot_clickOnPoint(const QPointF& ptSeries);    //获取曲线句柄

private:
    bool clicked;   //鼠标按下
    QLineSeries* series;    //系列
    QPointF ptNew;  //离鼠标最近的点
};

#endif // XCUSTOMCHART_H
